feat: add job and task creation#6
Conversation
asafMasa
commented
Aug 23, 2021
| Question | Answer |
|---|---|
| New feature | ✔ |
| } | ||
|
|
||
| public async updateTask(jobId: string, taskId: string, payload: IUpdateTaskRequestPayload): Promise<void> { | ||
| public async createTask(jobId: string, payload: IUpdateTaskBody): Promise<void> { |
There was a problem hiding this comment.
rename to enqueue
| const createJobUrl = `/jobs`; | ||
| await this.post(createJobUrl, payload); | ||
| } catch (err) { | ||
| this.logger.error(`failed to create job`); |
There was a problem hiding this comment.
add data to log.
what job?
| const logFormat = `jobId=${jobId}, taskId=${taskId}`; | ||
| try { | ||
| this.logger.info(`get task ${logFormat}`); | ||
| this.logger.info(`${logFormat} get task`); |
There was a problem hiding this comment.
make logs more readable
| return task; | ||
| } catch (err) { | ||
| this.logger.error(`failed to get task ${logFormat}`); | ||
| this.logger.error(`${logFormat} failed to get task`); |
There was a problem hiding this comment.
make logs more readable
| const tasks = await this.get<ITaskResponse[]>(getTaskUrl); | ||
| return tasks; | ||
| } catch (err) { | ||
| this.logger.error(`${logFormat} failed to get tasks`); |
There was a problem hiding this comment.
make logs more readable
| return task; | ||
| } catch (err) { | ||
| this.logger.error(`failed to get task ${logFormat}`); | ||
| this.logger.error(`[JobManagerClient][getTask] jobId=${jobId}, taskId=${taskId} failed to get task`); |
There was a problem hiding this comment.
add error message
| const tasks = await this.get<ITaskResponse[]>(getTaskUrl); | ||
| return tasks; | ||
| } catch (err) { | ||
| this.logger.error(`[JobManagerClient][getTasksForJob] jobId=${jobId} failed`); |
There was a problem hiding this comment.
add error message
| return job; | ||
| } catch { | ||
| this.logger.error(`failed to get job data for job: ${jobId}`); | ||
| this.logger.error(`[JobManagerClient][getJob] jobId=${jobId} failed`); |
There was a problem hiding this comment.
add error message
| return null; | ||
| } else { | ||
| this.logger.error(`failed to consume ${logFormat}`); | ||
| this.logger.error(`[JobManagerClient][consume] jobType=${this.jobType}, taskType=${this.taskType}, failed to consume`); |
There was a problem hiding this comment.
add error message
| const createTaskUrl = `/jobs/${jobId}/tasks`; | ||
| await this.post(createTaskUrl, payload); | ||
| } catch (err) { | ||
| this.logger.error(`[JobManagerClient][enqueueTask] jobId=${jobId}, payload=${JSON.stringify(payload)} failed`); |
There was a problem hiding this comment.
add error message
| const createJobUrl = `/jobs`; | ||
| await this.post(createJobUrl, payload); | ||
| } catch (err) { | ||
| this.logger.error(`[JobManagerClient][createJob] payload=${JSON.stringify(payload)} failed`); |
There was a problem hiding this comment.
add error message
| await this.put(updateTaskUrl, payload); | ||
| } catch (err) { | ||
| this.logger.error(`failed to update task ${logFormat}`); | ||
| this.logger.error(`[JobManagerClient][updateTask] jobId=${jobId}, taskId=${taskId}, payload=${JSON.stringify(payload)} failed`); |
There was a problem hiding this comment.
add error message
| await this.put(updateJobUrl, payload); | ||
| } catch (err) { | ||
| this.logger.error(`failed to update job Id=${jobId}`); | ||
| this.logger.error(`[JobManagerClient][updateJob] jobId=${jobId}, payload=${JSON.stringify(payload)} failed`); |
There was a problem hiding this comment.
add error message